import { defineStore } from 'pinia'
import a1 from '@/assets/home/a1.png'
import a0 from '@/assets/home/a0.png'
import a2 from '@/assets/home/a2.png'
import a3 from '@/assets/home/a3.png'
import a4 from '@/assets/home/a4.png'
import a5 from '@/assets/home/a5.png'
import a6 from '@/assets/home/a6.png'
import a7 from '@/assets/home/a7.png'
import a8 from '@/assets/home/a8.png'
import a9 from '@/assets/home/a9.png'
import b1 from '@/assets/home/b1.png'
import b0 from '@/assets/home/b0.png'
import b2 from '@/assets/home/b2.png'

import b3 from '@/assets/home/b3.png'

import b4 from '@/assets/home/b4.png'
import b5 from '@/assets/home/b5.png'
import b6 from '@/assets/home/b6.png'
import b7 from '@/assets/home/b7.png'
import b8 from '@/assets/home/b8.png'
import b9 from '@/assets/home/b9.png'
import { useUserStore } from './user'

import {
  darkTheme,
} from 'naive-ui'
export const useAppStore = defineStore({
  id: 'App',
  state: () => {
    return {
      theme: 'light',
      mainColor: import.meta.env.VITE_APP_BASE_COLOR,
      AllMenuList: [
        {
          name: '监测数据',
          path: '/dataManagement',
          icon: 'icon-daily-monitoring',
          Aing: a1,
          Bing: b1
        },
        {
          name: '用户设置',
          path: '/userPage',
          icon: 'icon-setting-user',
          Aing: b9,
          Bing: a9,
        },
        {
          name: '项目管理',
          path: '/projectManagement',
          icon: 'icon-project_management',
          Aing: a2,
          Bing: b2,
        },
        {
          name: '设备管理',
          path: '/deviceManagement',
          icon: 'icon-xiangmuguanli',
          Aing: a3,
          Bing: b3
        },
        {
          name: '报警设置',
          path: '/AlarmSetting',
          icon: 'icon-baojingshezhi1',
          Aing: a4,
          Bing: b4
        },
        {
          name: '报警记录',
          path: '/alarmApparatus',
          icon: 'icon-baojingjilu',
          Aing: a5,
          Bing: b5
        },
        {
          name: '设备数据',
          path: '/transducer',
          icon: 'icon-lishishuju1',
          Aing: a0,
          Bing: b0
        },
        {
          name: '报表数据',
          path: '/historicalData',
          icon: 'icon-lishishuju1',
          Aing: a6,
          Bing: b6
        },
        // {
        //   name: '日志报表',
        //   path: '/journalSheet',
        //   icon: 'icon-Vector',
        //   Aing: a7,
        //   Bing: b7
        // },
        {
          name: '系统设置',
          path: '/setting',
          icon: 'icon-shezhi',
          Aing: a8,
          Bing: b8
        },
      ],

      tEquipmentControllerList: [],

      Fullscreen: true,
      appInfo: {},
      isMobile: false
    }
  },
  getters: {
    isDark: state => state.theme === 'dark' ? darkTheme : null,
    menuList: state => {
      const userStore = useUserStore()
      let filterList = ['/userPage', '/deviceManagement', '/projectManagement', '/AlarmSetting', '/historicalData']
      // filterList = []
      return userStore.userInfo.auth == 1 ? state.AllMenuList : state.AllMenuList.filter(v => !filterList.includes(v.path))
    }
  },
  actions: {
    // upNum(val) {
    //   this.num += val
    // },
    setAppType() {
      this.isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Huawei|Honor|EMUI|HarmonyOS|MicroMessenger|Windows Phone|Mobile|SymbianOS|Nokia|UCWEB|Opera Mobi|Maemo|webOS|webOS|BlackBerry|Tablet|Mobile Safari/i.test(navigator.userAgent)
    },

    // useAutoDark: () => console.log(this.theme),
    useAutoDark() {
      this.theme = this.theme === 'light' ? 'dark' : 'light'
      if (this.theme === 'dark')
        document.documentElement.className = 'dark'
      else
        document.documentElement.removeAttribute('class')
    },
    getAppInfo() {
      Promise.all([tEquipmentControllerGettype()])
        .then((res) => {
          console.log(res, 'res')
          this.tEquipmentControllerList = res[0].result
        })
        .catch((err) => {
          console.log(err)
        })


    }
  },
})
